| 1 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  Copyright (C) 2018-2020 KANOUN Salim | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  This program is free software; you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  it under the terms of the Affero GNU General Public v.3 License as published by | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  the Free Software Foundation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  This program is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  Affero GNU General Public Public for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  You should have received a copy of the Affero GNU General Public Public along | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  with this program; if not, write to the Free Software Foundation, Inc., | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * check all require filds in a form before submit | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | function checkForm(form) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	 var inputs = form.elements; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 		for (var i = 0; i < inputs.length; i++) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 			if(inputs[i].hasAttribute("required")){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 		        if(inputs[i].value == ""){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 		            // found an empty field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 		        	alertifyError("Please fill in all fields"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 		            return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 		        } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  * Change color of key text value in the tables | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  * @returns | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | function changeColor(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	//Polly fill for IE11 missing function | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	if (!String.prototype.includes) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		  Object.defineProperty(String.prototype, 'includes', { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 		    value: function(search, start) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		      if (typeof start !== 'number') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 		        start = 0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 		      } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		       | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 		      if (start + search.length > this.length) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 		        return false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 		      } else { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		        return this.indexOf(search, start) !== -1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		      } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		  }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |   //on parcours tout les tableaux (balises table) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |   $("table:visible").each(function (i, el){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     //si la table a un id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     if(el.id != ""){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |       //on parcours chaque clonne de la table (identifiée grace à son id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |       $('#'+el.id+' tr').each(function (i, el){ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     	   | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $(this).find('td').each (function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |           if( $(this).html().includes("Not Done") || $(this).html().includes("Refused") ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             $(this).css('color', '#D53333'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |           } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |          else if( $(this).html().includes("Done") || $(this).html().includes("Accepted") ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             $(this).css('color', '#47B236)'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |          } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |          else if($(this).html().includes("Should be done") || $(this).html().includes("Wait Definitive Conclusion") || $(this).html().includes("Draft") || $(this).html().includes("Corrective Action Asked")){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             $(this).css('color', '#E29300'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |       }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |   }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  * Download documentation by id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  * @param id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  * @returns | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 84 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  | function downloadDocumentation(id){ | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  | 	window.location="scripts/download_documentation.php?idDocumentation="+id; | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | function alertifyError(message){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 	alertify.error(message); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | function alertifyWarning(message){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 	alertify.warning(message); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | function alertifySuccess(message){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 	alertify.success(message); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | function alertifyMessage(message) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 	alertify.message(message); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | function µ(str) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	// Escape & < > " chars | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 	return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | function checkBrowserSupportDicomUpload(selectorDom) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 	var isSupported = { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 		webKitDirectory: (function () { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 			var elem = document.createElement('input'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 				dir = 'directory', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 				domPrefixes = ["", "moz", "o", "ms", "webkit"], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 				prefix; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 			elem.type = 'file'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			for (prefix in domPrefixes) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 				if (domPrefixes[prefix] + dir in elem) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 					return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		})(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 		ecmascript6: (function () { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 			try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 				new Function("(a = 0) => a"); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 				return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 			catch (err) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 		})() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 	if (!isSupported['ecmascript6']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 		$(selectorDom).append('\ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 			<div class="alert alert-danger" role="alert">\ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 				Sorry, your browser does not support the DICOM Uploader. Please use Firefox 54+, Opera 62+, Edge 17+, Safari 12+, Chrome 58+ or newer versions.\ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 			</div>\ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 		'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 		throw 'ECMAScript6 not supported.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 	if (!isSupported['webKitDirectory']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 		$(selectorDom).append('\ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 			<div class="alert alert-warning" role="alert">\ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 				Be carefull, your browser does not support \'WebKitDirectory\'. Use drag and drop when importing files instead of using the browsing window. (You can also change your browser for Firefox 54+, Opera 62+, Edge 17+, Safari 12+, Chrome 58+ or newer versions)\ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 			</div>\ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 		'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | const preventDefault = function (event){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 	event.preventDefault(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	event.returnValue = ''; // Needed for Chrome | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  * Set listeners on page changing and page refreshing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  * The user will be asked to confirm before updating the page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | function preventAjaxDivLoading() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 	// Prevent page changing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 	window.addEventListener('beforeunload', preventDefault); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 	// Prevent ajax div loading | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	$(document).ajaxSend((evt, request, settings) => { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 		request.abort(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 		alertify.confirm('Close?', 'Your upload will be lost. Do you want to <strong>cancel the upload</strong>? </br> In that case, Click OK and redo your action.', () => { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 			//SK CANCEL DANS L UPLOADER? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 			$(document).off('ajaxSend'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 			refreshInvestigatorDiv(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 		}, () => { }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 	}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | function allowAjaxDivLoading(){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 	window.removeEventListener('beforeunload', preventDefault); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 	$(document).off('ajaxSend'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 187 |  |  |  |